package org.ypx.center.controller.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.ypx.center.controller.BaseController;
import org.ypx.center.service.BaseService;
import org.ypx.shared.common.Result;

import java.util.List;

/**
 * @author tingwen
 * @date 2017/3/28 21:06
 * @description
 */
@Controller
public abstract class BaseControllerImpl<T> implements BaseController<T> {
    @Autowired
    private BaseService<T> baseService;

    @RequestMapping("save.do")
    @ResponseBody
    @Override
    public Result<List<T>> save(T entity) {
        return baseService.save(entity);
    }

    @RequestMapping("delete.do")
    @ResponseBody
    @Override
    public Result<List<T>> delete(T entity) {
        return baseService.delete(entity);
    }

    @RequestMapping("update.do")
    @ResponseBody
    @Override
    public Result<List<T>> updateNotNull(T entity) {
        return baseService.updateNotNull(entity);
    }

    @RequestMapping("select.do")
    @ResponseBody
    @Override
    public Result<List<T>> select(T entity) {
        return baseService.select(entity);
    }
}
